<!-- 搜索表单 -->
<template>
  <div class="searchContainer">
    <el-card class="box-card"
             body-style="margin: 22px 22px 0 22px;"
             shadow="never">
      <el-form label-width="77px"
               class="ele-form-search"
               @keyup.enter.native="search"
               @submit.native.prevent
               :rules="rules"
               ref="where"
               :model="where">
        <el-row :gutter="15">

          <!-- <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 8 }">
            <el-form-item label="所在地区"
                          prop="accountInstCode">
              <regions-select v-model="where.subName"
                              placeholder="请选择所在地区"
                              @input="(event) => regionsInput(event, 'accountInstCode')" />
            </el-form-item>
          </el-col> -->

          <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 7 }">
            <el-form-item label="技师性别:"
                          prop="parentCode">
              <el-select clearable
                         class="ele-block"
                         v-model="where.gender"
                         placeholder="请技师技师性别">
                <el-option v-for="(i, j) in genderList"
                           :key="j"
                           :label="i.label"
                           :value="i.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 8 }">
            <el-form-item label="技师名称:"
                          prop="subName">
              <el-input clearable
                        v-model="where.technicianName"
                        placeholder="请输入技师名称" />
            </el-form-item>
          </el-col>
          <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 7 }">
            <el-form-item label="服务状态:"
                          prop="parentCode">
              <el-select clearable
                         class="ele-block"
                         v-model="where.status"
                         placeholder="请选择技师服务状态">
                <el-option v-for="(i, j) in serviceStatusList"
                           :key="j"
                           :label="i.label"
                           :value="i.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 8 }">
            <el-form-item label="认证状态"
                          prop="oemCode">
              <el-select clearable
                         class="ele-block"
                         v-model="where.authenticationNot"
                         placeholder="请选择认证状态">
                <el-option v-for="(i, j) in realNameAuthenticationList"
                           :key="j"
                           :label="i.label"
                           :value="i.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 8 }">
            <el-form-item label="申请时间:"
                          prop="dateRange">
              <el-date-picker v-model="where.dateRange"
                              type="datetimerange"
                              unlink-panels
                              range-separator="至"
                              start-placeholder="开始时间"
                              end-placeholder="结束时间"
                              :default-time="['00:00:00', '23:59:59']"
                              value-format="yyyy-MM-ddTHH:mm:ss"
                              class="ele-fluid" />
            </el-form-item>
          </el-col>
          <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 8 }">
            <div class="ele-form-actions">
              <el-button type="primary"
                         icon="el-icon-search"
                         class="ele-btn-icon"
                         @click="search">
                查询
              </el-button>
              <el-button @click="resetForm('where')">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
  </div>
</template>
<script>
import RegionsSelect from '@/components/RegionsSelect/index.vue';
import { getRegionLabel } from 'ele-admin/packages/utils/regions';
import {
  serviceStatusList,
  realNameAuthenticationList,
  categoryList,
  genderList
} from '../constant/constant';
export default {
  name: 'SystemUser',
  components: {
    // RegionsSelect
  },
  data () {

    // 默认表单数据
    const defaultWhere = {
      //   技师名称
      technicianName: '',
      // 服务状态
      status: '',
      // 技师评分
      scoreTotal: '',
      gender: '',
      //   认证状态
      authenticationNot: '',
      // 申请时间
      dateRange: [],
      imgViewArr: []
    };
    return {
      genderList,
      serviceStatusList,
      realNameAuthenticationList,
      categoryList,
      // 表单数据
      where: {
        ...defaultWhere
      },
      sumbitForm: {}
    };
  },
  props: {
    typeList: Array,
    oemList: {
      type: Array,
      default: () => []
    },
    secondaryList: {
      type: Array,
      default: () => []
    },
    currentPlatform: {
      type: String,
      default: ''
    }
  },
  computed: {
    // 是否开启响应式布局
    styleResponsive () {
      return this.$store.state.theme.styleResponsive;
    }
  },
  methods: {
    /* 搜索 */
    search () {
      for (const key in this.where) {
        if (key == 'dateRange') {
          let startTime = this.where[key]?.[0];
          let endTime = this.where[key]?.[1];
          this.sumbitForm['createTimeStart'] =
            startTime == undefined ? '' : startTime;
          this.sumbitForm['createTimeEnd'] = endTime == undefined ? '' : endTime;
        } else if (key == 'scoreTotal') {
          if (this.where[key]) {
            const scoreTotalArr = this.where[key].split('-');
            console.log(scoreTotalArr);
            let scoreTotalstart = scoreTotalArr[0];
            let scoreTotalEnd = scoreTotalArr[1];
            this.sumbitForm['scoreTotalStart'] = scoreTotalstart;
            this.sumbitForm['scoreTotalEnd'] = scoreTotalEnd;
          }
        } else {
          this.sumbitForm[key] = this.where[key];
        }
      }
      //   console.log(this.sumbitForm)
      this.$emit('search', this.sumbitForm);
    },

    /*  重置 */
    resetForm (formName) {
      this.$refs[formName].resetFields();

      this.where = {};
      this.sumbitForm = {};
      this.$emit('search', this.sumbitForm);
    }
  }
};
</script>
<style lang="less" scoped>
.searchContainer {
  padding-bottom: 15px;
}
/deep/ .el-form-item__label {
  text-align: inherit;
}
.navList {
  margin-bottom: 25px;
  font-weight: 700;
}
</style>
